@echo off
REM 声明采用UTF-8编码
chcp 65001

echo "Start new branch script..."

::echo "input branch"
::set /p branch=
::echo "branch: %branch%"

::echo "input new branch"
::set /p new_branch=
::echo "new branch: %new_branch%"

:: 执行检出新分支迭代
echo "===> 正在从远程分支/%branch%建立新分支%new_branch%"
call git -c core.quotepath=false -c log.showSignature=false checkout -b %new_branch% origin/%branch% --
:: 3、新分支打上快照
echo "===> 新分支已创建在本地，是否为其打上快照? (y/n)"
set /p snapshot=

if '%snapshot%' == 'n' goto skipSnapshot
if '%snapshot%' == 'y' goto makeSnapshot

:skipSnapshot
call mvn versions:set -DnewVersion=%new_branch% -DgenerateBackupPoms=false
goto push

:makeSnapshot
call mvn versions:set -DnewVersion=%new_branch%-SNAPSHOT -DgenerateBackupPoms=false
goto push

:: 4、推送新分支至远程，升级结束
:push
echo "===> push"
call git add .
call git commit -m "[update]创建%new_branch%分支"
call git push -u origin %new_branch%